<template>
    <el-sub-menu v-if="item.children?.length" :index="item.path">
        <template #title>
            <el-icon v-if="item.icon">
                <component :is="icons[item.icon]" />
            </el-icon>
            <span>{{ item.title }}</span>
        </template>
        <menu-item v-for="child in item.children" :key="child.path" :item="child" />
    </el-sub-menu>
    <el-menu-item v-else :index="item.path">
        <el-icon v-if="item.icon">
            <component :is="icons[item.icon]" />
        </el-icon>
        <template #title>{{ item.title }}</template>
    </el-menu-item>
</template>

<script setup>
import * as icons from '@element-plus/icons-vue'

defineProps({
    item: {
        type: Object,
        required: true,
        validator: (value) => {
            return 'path' in value && 'title' in value
        }
    }
})
</script>

<style>

</style>

